using System;
using System.ComponentModel;
//using System.Collections.Generic;

namespace needle.Services.astra.Collections
{
	/// <summary>
	/// Interface for paging of content.
	/// </summary>
	/// <remarks>
	/// <see cref="INotifyPropertyChanged.PropertyChanged"/> is fired when
	/// <see cref="Page"/> or
	/// <see cref="PageUI"/> or
	/// <see cref="PageSize"/> or
	/// <see cref="PageCount"/>
	/// is changed.
	/// </remarks>
	public interface IPaging : INotifyPropertyChanged
	{
		/// <summary>
		/// Current page.
		/// </summary>
		/// <remarks>
		/// Uses zero based indexing.
		/// </remarks>
		/// <value>Default: 0.</value>
		/// <exception cref="ArgumentOutOfRangeException">
		/// set: Value is not in range &lt;0, <see cref="PageCount"/>).
		/// </exception>
		int Page
		{
			get;
			set;
		}
		/// <summary>
		/// Current page usefull for UI.
		/// </summary>
		/// <remarks>Uses one based indexing.</remarks>
		/// <value>Default: 1.</value>
		/// <exception cref="ArgumentOutOfRangeException">
		/// set: Value is not in range &lt;1, <see cref="PageCount"/>&gt;.
		/// </exception>
		int PageUI
		{
			get;
			set;
		}
		/// <summary>
		/// Size of page as number of items on one page - actual number of such items can be smaller (on last page) but never bigger.
		/// </summary>
		/// <value>
		/// 0 means no paging (1 page).
		/// Default: 0.
		/// </value>
		/// <exception cref="ArgumentOutOfRangeException">set: Value is &lt; 0.</exception>
		int PageSize
		{
			get;
			set;
		}
		/// <summary>
		/// Number of pages.
		/// </summary>
		/// <value>
		/// 0 means no paging (1 page).
		/// Default: 1.
		/// </value>
		/// <exception cref="ArgumentOutOfRangeException">set: Value is &lt; 0.</exception>
		int PageCount
		{
			get;
			set;
		}

		/// <summary>
		/// Changes <see cref="Page"/> if needed.
		/// </summary>
		/// <param name="page">Page position.</param>
		void GoToPage(Pages page);
	}


	/// <summary>
	/// Pages of content.
	/// </summary>
	public enum Pages : byte
	{
		/// <summary>
		/// Current page.
		/// </summary>
		Current = 1,
		/// <summary>
		/// First page.
		/// </summary>
		First = 2,
		/// <summary>
		/// Previous page from current one.
		/// </summary>
		Previous,
		/// <summary>
		/// Next page from current one.
		/// </summary>
		Next,
		/// <summary>
		/// Last page.
		/// </summary>
		Last
	}
}
